//
// Tables
// --------------------------------------------------

table {
  border-radius: 6px;
  th {
    background-color: var(--background-color);
  }
  // Table cell sizing
  //
  // Reset default table behavior

  col[class*="col-"] {
    position: static; // Prevent border hiding in Firefox and IE9-11 (see https://github.com/twbs/bootstrap/issues/11623)
    display: table-column;
    float: none;
  }

  td,
  th {
    &[class*="col-"] {
      position: static; // Prevent border hiding in Firefox and IE9-11 (see https://github.com/twbs/bootstrap/issues/11623)
      display: table-cell;
      float: none;
    }
  }
  .h5 {
    font-size: 1em;
  }
}

caption {
  padding-top: $table-cell-padding;
  padding-bottom: $table-cell-padding;
  color: $text-muted;
  text-align: left;
}

th {
  text-align: left;
}

// Baseline styles

.table {
  width: 100%;
  max-width: 100%;
  margin-bottom: $line-height-computed;
  // Cells
  th {
    &:first-child {
      border-top-left-radius: 6px;
    }
    &:last-child {
      border-top-right-radius: 6px;
    }
  }
  > thead,
  > tbody,
  > tfoot {
    > tr {
      > td {
        padding: $table-cell-padding;
        line-height: $line-height-base;
        vertical-align: top;
        border-top: 1px solid $table-border-color;
      }
    }
  }
  // Bottom align for column headings
  > thead > tr > th {
    vertical-align: bottom;
    border-bottom: 2px solid $table-border-color;
  }
  // Remove top border from thead by default
  > caption + thead,
  > colgroup + thead,
  > thead:first-child {
    > tr:first-child {
      > th,
      > td {
        border-top: 0;
      }
    }
  }
  // Account for multiple tbody instances
  > tbody + tbody {
    border-top: 2px solid $table-border-color;
  }
}

// Condensed table w/ half padding

.table-condensed {
  > thead,
  > tbody,
  > tfoot {
    > tr {
      > th,
      > td {
        padding: $table-condensed-cell-padding;
      }
    }
  }
}

// Bordered version
//
// Add borders all around the table and between all the columns.

.table-bordered {
  border: 1px solid var(--grey-300);
  tbody {
    tr {
      td:not(:last-child),
      th:not(:last-child) {
        border-right: 1px solid var(--grey-400);
      }
    }
  }
}

// Zebra-striping
//
// Default zebra-stripe styles (alternating gray and transparent backgrounds)

.table-striped {
  > tbody > tr:nth-of-type(odd) {
    background-color: var(--table-stripe-color);
  }
}

// Hover effect
//
// Placed here since it has to come after the potential zebra striping

.table-hover {
  > tbody > tr:hover {
    background-color: var(--background-color-accent-lvl2);
  }
}

// Table backgrounds
//
// Exact selectors below required to override `.table-striped` and prevent
// inheritance to nested tables.

// Generate the contextual variants
@include table-row-variant("active", $table-bg-active);
@include table-row-variant("success", $state-success-bg);
@include table-row-variant("info", $state-info-bg);
@include table-row-variant("warning", $state-warning-bg);
@include table-row-variant("danger", $state-danger-bg);

// Responsive tables
//
// Wrap your tables in `.table-responsive` and we'll make them mobile friendly
// by enabling horizontal scrolling. Only applies <768px. Everything above that
// will display normally.

.table-responsive {
  min-height: 0.01%; // Workaround for IE9 bug (see https://github.com/twbs/bootstrap/issues/14837)
  overflow-x: auto;

  @media screen and (max-width: $screen-xs-max) {
    width: 100%;
    margin-bottom: ($line-height-computed * 0.75);
    overflow-y: hidden;
    -ms-overflow-style: -ms-autohiding-scrollbar;
    border: 1px solid $table-border-color;

    // Tighten up spacing
    > .table {
      margin-bottom: 0;

      // Ensure the content doesn't wrap
      > thead,
      > tbody,
      > tfoot {
        > tr {
          > th,
          > td {
            white-space: nowrap;
          }
        }
      }
    }

    // Special overrides for the bordered tables
    > .table-bordered {
      border: 0;

      // Nuke the appropriate borders so that the parent can handle them
      > thead,
      > tbody,
      > tfoot {
        > tr {
          > th:first-child,
          > td:first-child {
            border-left: 0;
          }
          > th:last-child,
          > td:last-child {
            border-right: 0;
          }
        }
      }

      // Only nuke the last row's bottom-border in `tbody` and `tfoot` since
      // chances are there will be only one `tr` in a `thead` and that would
      // remove the border altogether.
      > tbody,
      > tfoot {
        > tr:last-child {
          > th,
          > td {
            border-bottom: 0;
          }
        }
      }
    }
  }
}

@import "variables";
.table {
  border-collapse: inherit;

  thead,
  tbody,
  tfoot {
    tr > td {
      border-top: 1px solid var(--table-line-color);
    }
    tr.success {
      th,
      td {
        background-color: lighten($bg-success, 10%);
      }
      &:hover {
        th,
        td {
          background-color: lighten($bg-success, 5%);
        }
      }
    }

    tr.info {
      th,
      td {
        background-color: lighten($bg-info, 10%);
      }
      &:hover {
        th,
        td {
          background-color: lighten($bg-info, 5%);
        }
      }
    }

    tr.warning {
      th,
      td {
        background-color: lighten($bg-warning, 10%);
      }
      &:hover {
        th,
        td {
          background-color: lighten($bg-warning, 5%);
        }
      }
    }

    tr.danger {
      th,
      td {
        background-color: lighten($bg-danger, 10%);
      }
      &:hover {
        th,
        td {
          background-color: lighten($bg-danger, 5%);
        }
      }
    }
  }
  > thead > tr > th {
    border-bottom-width: 0;
    font-size: $font-size-h5;
    font-weight: $font-weight-light;
  }

  .radio,
  .checkbox {
    margin-top: 0;
    margin-bottom: 22px;
    padding: 0;
    width: 15px;
  }
  > thead > tr > th,
  > tbody > tr > th,
  > tfoot > tr > th,
  > thead > tr > td,
  > tbody > tr > td,
  > tfoot > tr > td {
    padding: 12px 11px;
    vertical-align: middle;
  }

  .th-description {
    max-width: 150px;
  }
  .td-price {
    font-size: 26px;
    font-weight: $font-weight-light;
    margin-top: 5px;
    text-align: right;
  }
  .td-total {
    font-weight: $font-weight-bold;
    font-size: $font-size-h5;
    padding-top: 20px;
    text-align: right;
  }

  .td-actions .btn {
    &.btn-sm,
    &.btn-xs {
      padding-left: 3px;
      padding-right: 3px;
    }
  }

  > tbody > tr {
    position: relative;
  }

  .has-switch {
    top: 9px;
    margin-top: -12px;
  }
}

.table-striped {
  tbody > tr:nth-of-type(2n + 1) {
    background-color: var(--table-stripe-color);
  }
  > thead > tr > th,
  > tbody > tr > th,
  > tfoot > tr > th,
  > thead > tr > td,
  > tbody > tr > td,
  > tfoot > tr > td {
    padding: 15px 8px;
  }
}
.table-shopping {
  > thead > tr > th {
    color: var(--muted-color);
    font-size: 1.1em;
    font-weight: $font-weight-light;
  }
  > tbody > tr > td {
    font-size: $font-paragraph;
    padding: 30px 5px;
    b {
      display: block;
      margin-bottom: 5px;
    }
  }
  .td-number,
  .td-price,
  .td-total {
    font-size: 1.2em;
    min-width: 130px;
    text-align: right;
    padding-right: 20px;

    small {
      margin-right: 3px;
    }
  }
  .td-product {
    min-width: 170px;
    padding-left: 30px;
    strong {
      color: var(--default-states-color);
      font-size: 1.2em;
      font-weight: $font-weight-bold;
    }
  }
  .td-number,
  .td-total {
    color: var(--default-states-color);
    font-weight: $font-weight-bold;
  }
  .td-quantity {
    .btn-group {
      margin-left: 10px;
    }
  }
  .img-container {
    border-radius: $border-radius-large;
    display: block;
    height: 100px;
    overflow: hidden;
    width: 100px;
    margin-left: 10px;

    img {
      width: 100%;
    }
  }
  .tr-actions > td {
    border-top: 0;
  }
}

.table-icons {
  display: inline-block;
  min-width: 110px;
}

// Element UI override

.el-table td,
.el-table th.is-leaf {
  border: none;
}
.el-table tr {
  z-index: 10;
}
.el-table {
  .el-checkbox__inner:hover,
  .el-checkbox__input.is-checked .el-checkbox__inner {
    background-color: var(--default-color);
    border-color: var(--default-color);
  }

  .el-checkbox__input.is-focus .el-checkbox__inner {
    border-color: var(--default-color);
  }
}

.el-table .el-table__footer .cell {
  font-weight: bold;
  font-size: $font-size-medium;
}
.el-table {
  tbody tr td:first-child,
  thead tr th:first-child {
    padding-left: $padding-base-horizontal;
  }
}

.card-plain .el-table {
  background-color: transparent;
  tr {
    background-color: transparent;
  }
}

.table.table-fixed {
  table-layout: fixed;
  > tbody > tr > td:first-child {
    width: 145px !important;
  }

  tfoot {
    tr > th,
    tr > td {
      word-break: break-word;
    }
  }
}

// VGT TABLE

@import "~vue-good-table-next/dist/vue-good-table-next.css";

div.vgt-responsive {
  width: 100%;
  overflow-x: inherit;
  position: relative;
}
.vgt-table.rd-table {
  border: 0 solid;
  background-color: var(--white);

  & tr.clickable {
    &:hover {
      background-color: var(--grey-100);
    }
  }

  // td
  & td {
    border-left: 0 solid;
    border-right: 0 solid;
    border-bottom: 1px solid var(--grey-400);
    color: var(--black);
    &:first-child {
      border-left: 1px solid var(--background-color-accent);
    }
  }

  //th
  & th.line-numbers,
  & th.vgt-checkbox-col {
    color: var(--font-color);
    border-right: 1px solid var(--background-color-lvl2);
    border-left: 1px solid var(--background-color-accent);
    background: var(--background-color-lvl2);
  }
  thead {
    border: 1px solid var(--background-color-accent);
    .vgt-checkbox-col {
      background: var(--background-color);
      border-right: 0 solid;
    }
  }
  tbody {
    border-right: 1px solid var(--grey-400);
  }
  thead th {
    border-bottom: 1px solid var(--background-color-accent);
    color: var(--font-color);
    background: var(--background-color);
    border: 0 solid;
    &.sortable {
      // color: lighten(var(--black), 15%);
      &:before {
        border-top-color: var(--grey-700);
      }
      &:after {
        border-bottom-color: var(--grey-700);
      }
      &.sorting-asc {
        color: var(--cyan-500);
        &:after {
          border-bottom-color: var(--blue-500);
        }
      }
      &.sorting-desc {
        color: var(--cyan-500);
        &:before {
          border-top-color: var(--blue-500);
        }
      }
    }
  }

  //bordered
  &.bordered td,
  &.bordered th {
    border-top: 1px solid var(--grey-400);
    border-bottom: 1px solid var(--grey-400);
  }

  //input
  .vgt-input,
  .vgt-select {
    color: var(--black);
    background-color: --grey-400;
    border: 1px solid var(--grey-400);
    &::placeholder {
      /* Chrome, Firefox, Opera, Safari 10.1+ */
      color: var(--black);
      opacity: 0.3; /* Firefox */
    }
  }
}
.vgt-inner-wrap {
  box-shadow: none;
}

.vgt-table th.sortable button {
  &:before {
    border-top: 5px solid var(--background-color-accent);
  }
  &:after {
    border-bottom: 5px solid var(--background-color-accent);
  }
}

// control bar
.vgt-inner-wrap .vgt-global-search {
  border-top: 1px solid var(--background-color-accent);
  border-left: 1px solid var(--background-color-accent);
  border-right: 1px solid var(--background-color-accent);
  background: linear-gradient(
    var(--background-color-lvl2),
    var(--background-color-lvl2)
  );
}

.vgt-inner-wrap .vgt-global-search__input {
  .input__icon {
    .magnifying-glass {
      border: 2px solid var(--background-color-accent) !important;
      &:before {
        background: var(--background-color-accent) !important;
      }
    }
  }
  .vgt-input {
    &::placeholder {
      color: var(--font-color);
    }
    color: var(--font-color);
    caret-color: var(--font-color);
    background-color: var(--input-bg-color);
    border: 1px solid var(--background-color-accent);
  }
}

.vgt-inner-wrap .vgt-wrap__footer {
  background: var(--background-color);
  border: 1px solid var(--background-color-accent);
  color: var(--font-color);
  .footer__navigation__page-btn {
    color: var(--font-color);
  }
}

.vgt-table.rd-table td {
  color: var(--font-color);
  background: var(--background-color-lvl2);
}
